<template>
  <div class="app-container">
     <el-row :gutter="20" >
      <!--项目数据-->
        <el-col :span="4" :xs="24" class="div_tree">
          <div class="head-container node ">
            <el-input v-model="projectName" placeholder="请输入节点名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
          </div>
          <div class="head-container tree ">
            <el-tree :data="projectTreeList"  :props="defaultProps" :highlight-current="true" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree" default-expand-all @node-click="handleNodeClick" />
          </div>
        </el-col>
        <!--用户数据-->
        <el-col :span="20" :xs="24">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="责任人" prop="userId">
            <treeselect v-model="queryParams.userId" :options="userTree" 
                :disable-branch-nodes="true" :show-count="false" 
                placeholder="请选择用户" style="width:180px"/>
          </el-form-item>
          <el-form-item label="审核人" prop="checkUserId">
            <treeselect v-model="queryParams.checkUserId" :options="userTree" 
              :disable-branch-nodes="true" :show-count="false" 
              placeholder="请选择用户" style="width:180px"/>
          </el-form-item>
          <el-form-item label="是否超时" prop="isTimeOut">
            <el-select v-model="queryParams.isTimeOut" placeholder="请选择是否超时" clearable size="small">
              <el-option
                v-for="dict in isTimeOutOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="是否输出" prop="isSubmitFile">
            <el-select v-model="queryParams.isSubmitFile" placeholder="请选择是否输出" clearable size="small">
              <el-option
                v-for="dict in isSubmitFileOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="开始时间" prop="startTime">
            <el-date-picker clearable size="small" style="width: 200px"
              v-model="queryParams.startTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择开始时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="工作状态" prop="state" class="item">
            <el-select v-model="queryParams.state" placeholder="请选择工作状态" clearable size="small">
              <el-option
                v-for="dict in stateOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
          <!-- <el-form-item>  
            <span>节点名称：{{this.queryRouter.projectName}}</span>
          </el-form-item> -->
        </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['project:user:add']"
            >新增工作</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['project:user:edit']"
            >修改工作</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['project:user:remove']"
            >删除工作</el-button>
          </el-col>
          <el-col :span="1.5">
            <!-- <el-button
              type="warning"
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['project:user:export']"
            >导出</el-button> -->
          </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="processList" @selection-change="handleSelectionChange" :row-class-name="tableRowClassName"  border style="width: 100%" height="600">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="主键ID" align="center" prop="itemId" v-if="false"/>
          <el-table-column label="责任人" align="center" prop="user.nickName" width="80" fixed/>
          <el-table-column label="工作时长" align="center" prop="fileHours" />
          <el-table-column label="工作内容" align="center" prop="workContent" width="500"/>
          <el-table-column label="所属组别" align="center" prop="workUserGroup" />
          <el-table-column label="开始时间" align="center" prop="startTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="结束时间" align="center" prop="finishTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.finishTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="完成时间" align="center" prop="realFinishTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.realFinishTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="是否输出" align="center" prop="isSubmitFile" :formatter="isSubmitFileFormat" />
          <el-table-column label="输出物名" align="center" prop="submitName" />
          <el-table-column label="是否超时" align="center" prop="isTimeOut" :formatter="isTimeOutFormat" />
          <!-- <el-table-column label="审核人" align="center" prop="checkUserName" /> -->
          <el-table-column label="状态" align="center" prop="state" :formatter="stateFormat" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  width="200" fixed="right">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-upload2"
                @click="handleFileUpload(scope.row)"
                v-hasPermi="['project:project:file']"
              >上传附件</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['project:user:edit']"
              >修改工作</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['project:user:remove']"
              >删除工作</el-button>
            </template>
          </el-table-column>
        </el-table>
        
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
    <!-- 添加或修改项目人员对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>

          <el-col :span="16">
             <el-form-item label="节点名称">
                <span>{{this.queryRouter.projectName}}</span>
             </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="人员选择" prop="isUser">
              <el-radio-group v-model="form.isUser" @change="isUserChange">
                <el-radio v-for="item in isUserTeamOptions" :key="item.value" :label="item.label" :value="item.value"></el-radio>
              </el-radio-group>
            </el-form-item>  
          </el-col>
          <el-col :span="8">
            <el-form-item label="负责人" prop="userId" v-if="isTeamUser">
              <el-select v-model="form.userId" @change="setFileHoursList" placeholder="请选择项目成员角色" clearable style="width:100%">
                <el-option
                  v-for="team in projectTeamUserOptions"
                  :key="team.teamId"
                  :label="team.nickName"
                  :value="team.userId">
                <span style="float: left">{{ team.nickName }}</span>
                <span style="float: right; color: #8492a6; font-size: 13px">{{ team.roleName }}</span>
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="负责人" prop="userId" v-if="isTreeUser" >
              <treeselect v-model="form.userId" :options="userTree" :multiple="false"
              :disable-branch-nodes="true" :show-count="false" 
              placeholder="请选择用户" style="width:100%" @select="userTreeFileHoursList"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="fileId" label="工作时长">
              <el-select v-model="form.fileId" clearable  style="width:100%">
                <el-option v-for="item in filesOptions" :key="item.fileId" :label="item.name" :value="item.fileId" :disabled="item.state == 1" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属组别" prop="workUserGroup">
              <el-select v-model="form.workUserGroup"  filterable  placeholder="请选择" prop="groups" style="width:100%">
                <el-option v-for="item in groupTypeOptions" :key="item.id" :label="item.name" :value="item.code" :disabled="item.states == 1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          
          <el-col :span="24">
            <el-form-item label="工作内容" prop="workContent" >
              <el-input v-model="form.workContent" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="开始时间" prop="startTime">
              <el-date-picker clearable size="small"  style="width:100%"
                v-model="form.startTime"
                type="date"
                :default-value="form.startTime"
                value-format="yyyy-MM-dd"
                placeholder="选择开始时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="结束时间" prop="finishTime">
              <el-date-picker clearable size="small"  style="width:100%"
                v-model="form.finishTime"
                type="date"
                :default-value="form.finishTime"
                value-format="yyyy-MM-dd"
                placeholder="选择结束时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否输出" prop="isSubmitFile" >
              <el-radio-group v-model="form.isSubmitFile"  @change="isSubmitFileChange">
                <el-radio v-for="dict in isSubmitFileOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="输出物名" prop="submitName">
              <el-input v-model="form.submitName" placeholder="请输入输出物名称" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
              <el-form-item label="审核人" prop="checkUserId">
                  <treeselect v-model="form.checkUserId" :options="userTree" :multiple="false"
                  :disable-branch-nodes="true" :show-count="false" 
                  placeholder="请选择审核人" style="width:100%"/>
              </el-form-item>
          </el-col>
          <el-col :span="24"  v-if="isPeopleWorkLineShow" >
                <AnalyzeEasyLineCharts class="middleTwo" :handleOfficeLineCharts="handlePeopleLineCharts" :chart-data="peopleCompositeLineCharts" />
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 上传文件 -->
     <el-dialog :title="upload.title" :visible.sync="upload.open" :close-on-click-modal="false"  width="800px" append-to-body>
      <el-tabs v-model="upload.activeName">
        <el-tab-pane id="fileUpload" label="上传" name="first">
              <el-upload ref="upload" 
              :headers="upload.headers" 
              :limit="1" 
              :data="upload.data"
              :action="upload.url" 
              :disabled="upload.isUploading" 
              :on-progress="handleFileUploadFile" 
              :on-success="handleFileSuccess" 
              :auto-upload="false" drag>
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">
                将文件拖到此处，或
                <em>点击上传</em>
              </div>
            </el-upload>
          <el-button type="primary" @click="submitFileForm" style="display:block;margin:0 auto;marginTop:1em">上 传</el-button>
        </el-tab-pane>
        <el-tab-pane label="附件查看" name="second">
            <el-row :gutter="10" class="mb8">
            </el-row>
            <el-table v-loading="loading" :data="upload.fileLists" border @selection-change="handleSelectionFileChange">
                  <el-table-column type="selection" width="55" align="center" />
                  <el-table-column label="文件ID" align="center" prop="id" v-if="false"/>
                  <el-table-column label="文件URL" align="center" prop="url" v-if="false"/>
                  <el-table-column label="文件名称" align="center" prop="name"/>
                  <el-table-column label="文件类型" align="center" prop="type" :formatter="stateFileTypeFormat" />
                  <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-edit"
                        @click="handleFileDownload(scope.row)"
                      >下载</el-button>
                      <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                        @click="handleFileDelete(scope.row)"
                        v-hasPermi="['project:project:fileremove']"
                      >删除</el-button>
                    </template>
                  </el-table-column>
            </el-table>
        </el-tab-pane>
      </el-tabs>
      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="submitFileForm">确 定</el-button> -->
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
// import { listUser, getUser, delUser, addUser, updateUser, exportUser, selectFiles } from "@/api/project/user";
import { listProcess, getProcess, delProcess, addProcessAndResolve,updateProcess, exportProcess,
 completeStates,selectFiles,downloadFile,completeCheckStates } from "@/api/work/user";
import { deleteFiles,listHours,projectTreeselect } from "@/api/project/projectTree";
import {groupList} from "@/api/work/process";
import {getUserTree} from "@/api/trialproduce/car";
import {getToken } from "@/utils/auth";
import { getTeamUser } from "@/api/project/team";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import AnalyzeEasyLineCharts from '../../statistics/linecharts/AnalyzeEasyLineChart';
import { queryPeopleCompositeTotalLineCharts } from "@/api/statistics/work/composite";
import echarts from 'echarts';
export default {
  name: "User",
  components: { 
      Treeselect,
      AnalyzeEasyLineCharts
  },
  data() {
    return {
      //基础路径
      baseURL : process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 项目人员表格数据
      processList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否超时字典
      isTimeOutOptions: [],
      //组别
      groupTypeOptions: [],
      // 文件时长选项
      filesOptions:[],
      //组织结构
      deptId: null,
      //用户数结构
      userTree:[],
      //文件类型
      textFileTypeOptions: [],
      //是否输出
      isSubmitFileOptions:[],
      //状态
      stateOptions: [],
      //项目组成员
      projectTeamUserOptions: [],
      //项目组用户
      isTeamUser: true,
      //中心用户
      isTreeUser: false,
      //人员近30天工作
      peopleCompositeLineCharts:{},
      //是否显示人员统计
      isPeopleWorkLineShow: false,
      //选择用户
      isUserTeamOptions:[
        { 
          value: '0',
          label: '全部'
        },
        {
          value: '1',
          label: '项目组'
        }
      ],
      // 项目管理表格数据
      projectTreeList: [],
      //查询数参数
      queryTreeParams:{
        relParentId:null
      },
      //树查询条件
      projectName:null,
      defaultProps: {
        children: "children",
        label: "label",
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        checkUserId: null,
        isTimeOut: null,
        startTime: null,
        workId: null,
        workType: "1"
      },
      //传递参数缓存
      queryRouter:{
          startTime: "",
          finishTime:"",
          deptId:"",
          projectName:""

      },
      team :{
          query: {
            projectId:null
          }
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
         userId: [
          { required: true, message: "责任人不能为空", trigger: "blur" }
        ],
        fileId: [
          { required: true, message: "工作时长不能为空", trigger: "blur" }
        ],
        workUserGroup: [
          { required: true, message: "所属组别不能为空", trigger: "blur" }
        ],
        startTime: [
          { required: true, message: "开始时间不能为空", trigger: "blur" }
        ],
        finishTime: [
          { required: true, message: "结束时间不能为空", trigger: "blur" }
        ],
        isSubmitFile: [
          { required: true, message: "是否输出不能为空", trigger: "blur" }
        ],
        submitName: [
          { required: true, message: "输出物名不能为空", trigger: "blur" }
        ],
        workContent: [
          { required: true, message: "工作内容不能为空", trigger: "blur" }
        ],
        checkUserId: [
          { required: true, message: "审核人不能为空", trigger: "blur" }
        ]
      },
      upload: {
        title: null,
        open: false,
        // 上传标签页
        activeName: 'first',
        // 设置上传的请求头部
        headers: { Authorization: 'Bearer ' + getToken()},
        // 是否禁用上传
        isUploading: false,
        // 上传的地址
        url: process.env.VUE_APP_BASE_API+"/work/process/user/upload",
        //路径
        baseURL:  process.env.VUE_APP_BASE_API,
        // 设置上传的请求头部
        headers: { Authorization: 'Bearer ' + getToken()},
        data: {
          tableId: null
        },
        //总数
        total: 0,
        fileLists: [{
          id:'',
          url: "",
          name: '',
          type: ''
        }],
      },
      //查询统计图参数
      queryTotal:{
          userId: null,
          beginTime: null,
          endTime: null
      },
    };
  },
  watch: {
    $route(){
      this.getList();//换成你的方法
    }
  },
  created() {
    const workId = this.$route.params && this.$route.params.projectId;
    const deptId = this.$route.query.deptId;
    this.queryParams.workId = workId;
    this.deptId = deptId;
    this.queryRouter.startTime = this.$route.query.startTime;
    this.queryRouter.finishTime = this.$route.query.finishTime;
    this.queryRouter.projectName = this.$route.query.projectName;
    this.team.query.projectId = this.$route.query.parentId;
    this.queryTreeParams.relParentId = workId;
    this.getList();
    this.handleGroupList();
    this.handleUserTree();
    this.handleTeamUserList();
    this.getProjectTreeselect();
    this.getDicts("sys_yes_no").then(response => {
      this.isTimeOutOptions = response.data;
    });
    this.getDicts("sys_file_type").then(response => {
      this.textFileTypeOptions = response.data;
    });
    this.getDicts("sys_yes_no").then(response => {
      this.isSubmitFileOptions = response.data;
    });
    this.getDicts("work_file_state").then(response => {
      this.stateOptions = response.data;
    });
  },
  watch: {
    // 根据名称筛选部门树
    projectName(val) {
      this.$refs.tree.filter(val);
    },
  },
  activated(){
    const workId = this.$route.params && this.$route.params.projectId;
    const deptId = this.$route.query.deptId;
    this.queryParams.workId = workId;
    this.deptId = deptId;
    this.queryRouter.startTime = this.$route.query.startTime;
    this.queryRouter.finishTime = this.$route.query.finishTime;
    this.queryRouter.projectName = this.$route.query.projectName;
    this.team.query.projectId = this.$route.query.parentId;
    this.queryTreeParams.relParentId = workId;
    this.getList();
  },
  methods: {
      // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.workId = data.id;
      this.queryRouter.projectName = data.label;
      this.getList();
    },
    /** 查询项目下拉树结构 */
    getProjectTreeselect() {
      projectTreeselect(this.queryTreeParams).then((response) => {
        this.projectTreeList = response.data;
      });
    },
    //用户树
    handleUserTree(){
      getUserTree().then(response => {
        this.userTree = response.data;
      });
    },
    //工作时长
    getFilesList(userId){
      listHours(userId).then((response) => {
        this.filesOptions = response.data;
      });
    },
    // 查询组别
    handleGroupList(){
      groupList().then((response) => {
        this.groupTypeOptions = response.data;
      });
    },
    /** 查询项目人员列表 */
    getList() {
      this.loading = true;
      listProcess(this.queryParams).then(response => {
        this.processList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 是否超时字典翻译
    isTimeOutFormat(row, column) {
      return this.selectDictLabel(this.isTimeOutOptions, row.isTimeOut);
    },
     // 是否提交输出物字典翻译
    isSubmitFileFormat(row, column) {
      return this.selectDictLabel(this.isSubmitFileOptions, row.isSubmitFile);
    },
    // 文件类型翻译
    stateFileTypeFormat(row, column) {
      return this.selectDictLabel(this.textFileTypeOptions, row.type);
    },
    // 任务状态翻译
    stateFormat(row, column) {
      return this.selectDictLabel(this.stateOptions, row.state);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        itemId: null,
        userId: null,
        checkUserId: null,
        fileHours: null,
        workUserGroup: null,
        isTimeOut: null,
        startTime: null,
        finishTime: null,
        relFinishTime: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null,
        isSubmitFile:'Y',
        isUser: "项目组",
        workType: "1"
      };
      this.isTeamUser = true;
      this.isTreeUser = false;
      this.filesOptions =[];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.itemId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.isPeopleWorkLineShow = false;
      this.form.startTime = this.queryRouter.startTime;
      this.form.finishTime = this.queryRouter.finishTime;
      this.form.workId = this.queryParams.workId;
      this.open = true;
      this.title = "添加项目人员";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      if(row.state!='0'){
           this.$message({
              type: 'info',
              message: '该工作已提交审核不能修改' 
            });
      }else{
          this.reset();
          this.isPeopleWorkLineShow = false;
          this.peopleCompositeLineCharts = {};
          const itemId = row.itemId || this.ids
          getProcess(itemId).then(response => {
            this.form = response.data;
            if('Y'==response.data.isSubmitFile){
              this.rules.submitName[0].required = true;
            }else{
                this.rules.submitName[0].required = false;
            }
            this.$set(this.form,"isUser","全部");
            this.isTeamUser = false;
            this.isTreeUser = true;
            this.getFilesList(this.form.userId);
            this.open = true;
            this.title = "修改项目人员";
        });
      }
      
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.itemId != null) {
            updateProcess(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addProcessAndResolve(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const itemIds = row.itemId || this.ids;
      this.$confirm('是否确认删除项目人员编号为"' + itemIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delProcess(itemIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有项目人员数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportProcess(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
    /** 附件上传按钮操作 */
    handleFileUpload(row) {
      const itemId = row.itemId;
      this.upload.title = "上传附件";
      this.upload.open = true;
      this.upload.data.tableId = itemId;
      this.getFileList();
    },
    // 附件上传中处理
    handleFileUploadFile(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 附件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = true;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "上传结果", { dangerouslyUseHTMLString: true });
      this.getFileList();
      this.getList();
    },
    // 附件提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
     //附件列表
    handleSelectionFileChange(selection){
      this.id = selection.map(item => item.id)
      this.uri = selection.map(item => item.uri)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 查询附件列表 */
    getFileList() {
      this.loading = true;
      selectFiles(this.upload.data.tableId).then((response) => {
        this.upload.fileLists = response.rows;
        this.upload.total = response.total;
        this.loading = false;
      });
    },
    // 删除文件操作
    handleFileDelete(row){
      const id = row.id || this.id;
      this.$confirm('是否确认删除任务分配编号为"' + id + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return deleteFiles(id);
        }).then(() => {
          this.getFileList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    // 下载文件
    handleFileDownload(row){
      const id = row.id || this.id;
      const url = row.uri || this.uri;
      window.location.href = this.baseURL+url;
    },
    //改变是否输出必填项
    isSubmitFileChange(value){
      if('Y'==value){
          this.rules.submitName[0].required = true;
      }else{
          this.rules.submitName[0].required = false;
      }
    },
    //设置用户选择权限
    isUserChange(value){
        this.filesOptions =[];
        this.form.userId = "";
        if('全部'==value){
          this.isTeamUser = false;
          this.isTreeUser = true;
        }else{
            this.isTeamUser = true;
            this.isTreeUser = false;
        }
    },
    // 查看项目组成员信息
    handleTeamUserList(){
      getTeamUser(this.team.query).then((response) => {
        this.projectTeamUserOptions = response.data;
      });
    },
    //设置文件工时参数
    setFileHoursList(value){
      this.$set(this.form,"fileId","");
      this.getFilesList(value);
      this.queryPeopleWorkLine();
    },
     //设置文件工时参数
    userTreeFileHoursList(value){
      this.$set(this.form,"fileId","");
      this.getFilesList(value.id);
      console.log(this.form.userId);
      this.queryPeopleWorkLine();
    },
    //修改列颜色
    tableRowClassName({row, rowIndex}) {
        if (row.isTimeOut === 'Y') {
          return 'danger-row';
        } else{
          return 'success-row';
        }
    },
    //校验时间是否符合要求
    checkTime(value){
        if(null == this.form.startTime){
            this.form.finishTime = null;
            this.$message({
              showClose: true,
              message: '请选择开始时间',
              type: 'warning'
            });
        }else{
             var result = this.compareTime(this.form.startTime,value)
             if(result==false){
                this.$message({
                  showClose: true,
                  message: '结束时间不能小于开始时间',
                  type: 'warning'
                });
                this.form.finishTime = null;
             }
        }
    },
     //查询人员工作曲线图
    queryPeopleWorkLine(){
      if(null==this.form.userId){
            this.$message({
              showClose: true,
              message: '请选人人员信息',
              type: 'warning'
            });
            return;
      }
      if(null==this.form.startTime||"" == this.form.startTime){
            this.$message({
              showClose: true,
              message: '请选择开始时间',
              type: 'warning'
            });
            return;
      }
      if(null==this.form.finishTime||"" == this.form.finishTime){
            this.$message({
              showClose: true,
              message: '请选择结束时间',
              type: 'warning'
            });
            return;
      }
      this.queryTotal.userId = this.form.userId;
      this.queryTotal.beginTime = this.form.startTime;
      this.queryTotal.endTime = this.form.finishTime;
      this.handlePeopleLineCharts(this.queryTotal);
      this.isPeopleWorkLineShow = true;
    },
    // 查询人员最近30天工作曲线
    handlePeopleLineCharts(params){
        let userName = "";
        queryPeopleCompositeTotalLineCharts(params).then(response => {
            let newObject = {
                xdata:[],
                ydata:[],
                zdata:[],
                adata:[],
                bdata:[]
            }  
            response.forEach((item,index)=>{
                newObject.xdata.push(item.time)
                newObject.ydata.push(item.totalValue)
                userName = item.name;
            })
            newObject.bdata.push(userName+":近30天工作量曲线（H）");
            this.peopleCompositeLineCharts = newObject
        });
    },
  }
};
</script>
<style  lang="scss">
.el-upload-list__item-name{
    font-size: 16px;
}
#fileUpload .el-upload-dragger{
  display:block;
  margin:0 auto;
  margin-top:1em;
  width: 760px;
  height: 180px;
}
.el-table .warning-row {
  background: rgb(248, 226, 186);
}

.el-table .success-row {
  background: #ffffff;
}

.el-table .danger-row {
  background: #f8b690;
}
.tree {
  .el-tree-node {
    white-space: normal;
    .el-tree-node__content {
      height: 100%;
      align-items: start;
      padding-top: 3%;
    }
  }
}
.div_tree {
   overflow:auto;
   max-height: 755px;
}

</style>